package com.smart.utils;

import com.smart.model.vo.ProjectVO;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ProjectGrouper {

    public static Map<Boolean, List<ProjectVO>> groupProjectsByScale(List<ProjectVO> projectVOList) {
        return projectVOList.stream()
                .collect(Collectors.partitioningBy(ProjectGrouper::isAboveScale));
    }

    private static boolean isAboveScale(ProjectVO projectVO) {
        boolean isAboveScale;

        if ("MUNICIPAL".equals(projectVO.getEngineeringType())) {
            isAboveScale = (projectVO.getEngineeringCost().multiply(new BigDecimal(10000))).compareTo(new BigDecimal("50000000")) >= 0;
        } else {
            isAboveScale = projectVO.getFloorArea().compareTo(new BigDecimal("10000")) >= 0;
        }

        return isAboveScale;
    }
}